package ysq.xyg.host.model.po;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.base.util.BaseUtil;
import ysq.xyg.sys.model.po.SysUser;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;

/**
 * 房产-楼盘实体类
 *
 * @author congcong tao
 * @date 2019-12-11 15:18:55
 */
@Data
@NoArgsConstructor
@Table(name = "xyg_host_item")
public class HostItem implements Serializable{

	/**
     * 主键
     */ 
	@Id
	private String id;

	/**
     * 应用主键
     */ 
	@Column(name = "account_id")
	private String accountId;

	/**
     * 城市主键
     */ 
	@Column(name = "city_id")
	private String cityId;

	/**
     * 区域主键
     */ 
	@Column(name = "area_id")
	private String areaId;

	/**
     * 名称
     */ 
	@Column(name = "name")
	private String name;

	/**
     * 房屋特色,逗号隔开的名称
     */ 
	@Column(name = "host_tag")
	private String hostTag;

	/**
     * 是否推荐1=否2=是
     */ 
	@Column(name = "is_recommend")
	private String isRecommend;

	/**
	 * 是否上架1=否2=是
	 */
	@Column(name = "is_grounding")
	private String isGrounding;

	/**
     * 房屋类型code码如住宅
     */ 
	@Column(name = "host_type")
	private String hostType;

	/**
     * 户型类型,用逗号隔开的code码id
     */ 
	@Column(name = "layout_type")
	private String layoutType;

	/**
     * 封面图片
     */ 
	@Column(name = "cover_image")
	private String coverImage;

	/**
     * 多图片
     */ 
	@Column(name = "images")
	private String images;

	/**
     * 佣金描述
     */ 
	@Column(name = "share_money")
	private String shareMoney;

	/**
     * 参考单价(1200/m)
     */ 
	@Column(name = "price")
	private String price;

	/**
     * 参考总价
     */ 
	@Column(name = "all_price")
	private String allPrice;

	/**
     * 最小户型
     */ 
	@Column(name = "min_rooms")
	private String minRooms;

	/**
     * 最大户型
     */ 
	@Column(name = "max_rooms")
	private String maxRooms;

	/**
     * 最小户型面积
     */ 
	@Column(name = "min_apartment_area")
	private String minApartmentArea;

	/**
     * 最大户型面积
     */ 
	@Column(name = "max_apartment_area")
	private String maxApartmentArea;

	/**
     * 详细地址
     */ 
	@Column(name = "address")
	private String address;

    /**
     * 经度
     */
    @Column(name = "longitude")
    private String longitude;

    /**
     * 纬度
     */
    @Column(name = "latitude")
    private String latitude;

	/**
     * 开盘时间
     */ 
	@Column(name = "open_time")
	private Date openTime;

	/**
     * 交房时间
     */ 
	@Column(name = "delivery_time")
	private Date deliveryTime;

	/**
     * 产权年限
     */ 
	@Column(name = "property_year")
	private String propertyYear;

	/**
     * 水电类型
     */ 
	@Column(name = "hydroelectric")
	private String hydroelectric;

	/**
     * 装修
     */ 
	@Column(name = "decorate")
	private String decorate;

	/**
     * 楼栋
     */ 
	@Column(name = "building")
	private String building;

	/**
     * 排序
     */ 
	@Column(name = "order_num")
	private Integer orderNum;

	/**
     * 创建者
     */ 
	@Column(name = "create_user")
	private String createUser;

	/**
     * 更新者
     */ 
	@Column(name = "update_user")
	private String updateUser;

	/**
     * 删除状态1、未删除2、已删除
     */ 
	@Column(name = "remove_tag")
	private String removeTag;

	/**
     * 创建时间
     */ 
	@Column(name = "create_time")
	private Date createTime;

	/**
     * 更新时间
     */ 
	@Column(name = "update_time")
	private Date updateTime;

	@Column(name = "manage_member_id")
	private String manageMemberId;

	@Transient
	private String manageMemberName;

	@Transient
	private String manageMemberPhone;

	@Transient
	private String manageMemberHeadImage;

	@Transient
	private String[] hostTypeList;

	public String[] getHostTagList() {
		if (StringUtils.isEmpty(hostTag)) {
			return new String[0];
		}
		return StrUtil.split(hostTag, ",");
	}

	public String[] getImageList() {
		if (StringUtils.isEmpty(images)) {
			return new String[0];
		}
		return StrUtil.split(images, ",");
	}

	public HostItem(SysUser sysUser) {
		this.id= BaseUtil.uId();
		this.accountId = sysUser.getAccountId();
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}
}